<!DOCTYPE html>
<html lang="">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1">
    <link rel="icon" href="dist/logo.ico">
    <title>思绪思维导图</title>
    <script>
        // 自定义静态资源的路径
        window.externalPublicPath = './dist/'
        // 接管应用
        window.takeOverApp = false

        // 直接粘贴 JSON 数据

        const embeddedJsonData = {
            "mindMapData": {
                "root": {
                    "data": {
                        "text": "根节点"
                    },
                    "children": []
                },
                "theme": {
                    "template": "avocado",
                    "config": {}
                },
                "layout": "logicalStructure",
                "config": {},
                "view": null
            },
            "lang": "zh",
            "localConfig": null
        };
    </script>
    <link href="dist/css/chunk-vendors.css?153f5047fdc3ef873534" rel="stylesheet">
    <link href="dist/css/app.css?153f5047fdc3ef873534" rel="stylesheet">
</head>
<body>
<noscript>
    <strong>抱歉，思维导图在未启用 JavaScript 的情况下无法正常工作。请启用 JavaScript 以继续。</strong>
</noscript>
<div id="app"></div>
<script>
    const getDataFromBackend = () => {
        return new Promise((resolve, reject) => {
            resolve({
                mindMapData: embeddedJsonData.mindMapData,
                lang: embeddedJsonData.lang,
                localConfig: embeddedJsonData.localConfig
            });
        });
    }

    const setTakeOverAppMethods = (data) => {
        window.takeOverAppMethods = {}
        // 获取思维导图数据的函数
        window.takeOverAppMethods.getMindMapData = () => {
            return data.mindMapData;
        }
        // 保存思维导图数据的函数
        window.takeOverAppMethods.saveMindMapData = (data) => {
            console.log(data)
        }
        // 获取语言的函数
        window.takeOverAppMethods.getLanguage = () => {
            return data.lang;
        }
        // 保存语言的函数
        window.takeOverAppMethods.saveLanguage = (lang) => {
            console.log(lang);
        }
        // 获取本地配置的函数
        window.takeOverAppMethods.getLocalConfig = () => {
            return data.localConfig;
        }
        // 保存本地配置的函数
        window.takeOverAppMethods.saveLocalConfig = (config) => {
            console.log(config);
        }
    }

    window.onload = async () => {
        if (!window.takeOverApp) return;

        const data = await getDataFromBackend();
        setTakeOverAppMethods(data);

        window.$bus.$on('app_inited', (mindMap) => {
            console.log(mindMap);
        });

        window.initApp();
    }
</script>
<script src="dist/js/chunk-vendors.js?153f5047fdc3ef873534"></script>
<script src="dist/js/app.js?153f5047fdc3ef873534"></script>

</body>
</html>
